package airacrobats.io;

import airacrobats.io.data.FlapsData;
import java.io.DataInputStream;
import java.io.IOException;
import javax.vecmath.Point3f;

/**
 * The flaps loader.
 */
public class FlapsLoader extends DataLoader<FlapsData>
{
    /**
     */
    @Override
    protected FlapsData load(DataInputStream dataInputStream) throws IOException
    {
        // Each line contains: the model file name, the translation position(x, y, z) if the flaps model
        // is centered, the pitch and roll factor (how these two attributes will rotate the flaps).
        String line = dataInputStream.readLine();

        String[] lineParams = line.split(" ");

        FlapsData flapsData = new FlapsData(lineParams[0], new Point3f(
                Float.parseFloat(lineParams[1]),
                Float.parseFloat(lineParams[2]),
                Float.parseFloat(lineParams[3])),
                Integer.parseInt(lineParams[4]),
                Integer.parseInt(lineParams[5]));

        return flapsData;
    }
}
